<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;

$this->title = Yii::t('app.cruise', 'Restaurants');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="restaurant-index">

    <h2 class="page-header"><?= Html::encode($this->title) ?>
        <p class="pull-right">
        <?= Html::a(Yii::t('app.cruise', 'Create Restaurant'),['create','cruise_id'=>$cruise_id],['class'=>'btn btn-success'])?>
        <?= Html::a(Yii::t('app', 'Index'), ['cruise/index'], ['class' => 'btn btn-danger']) ?>
        </p>
    </h2>
<?php Pjax::begin(); ?>    
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'layout'  =>  "{items}\n{pager}",
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],
            'cruise.name',
            'name',
            'en_name',
            'num',
            [
                'attribute' => 'spend',
                'filter' =>  Yii::$app->params['spend'],
                'value' => function ($model) {
                    return Yii::$app->params['spend'][$model->spend];
                },
            ],
            [
                'attribute' => 'status',
                'filter' =>  Yii::$app->params['status'],
                'value' => function ($model) {
                    return Yii::$app->params['status'][$model->status];
                },
                'format' => 'raw',
            ],
            [
                'label'=>'图片',
                'format'=>'raw',
                'value' => function($model){
                    $r =  urlencode(\yii::$app->request->getUrl());
                    $url = sprintf("/cruise/restaurant/image?id=%d", $model->id);
                    return Html::a('<i class="fa fa-image"></i>',$url,['title' => '图片', 'target'=>'_blank']);
                }
            ],
            [
                'class' => 'yii\grid\ActionColumn',
                'template' =>'{view} {update}'
            ],
        ],
    ]); ?>
<?php Pjax::end(); ?></div>
